package com.wider.applets;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import javax.swing.tree.DefaultMutableTreeNode;

public class serialization {
	public static void main(String[] args){
	DefaultMutableTreeNode node=new DefaultMutableTreeNode("TestNode");
	FileOutputStream fout;
	
	try {
		fout=new FileOutputStream("D:\\test.txt");
		ObjectOutputStream oout = new ObjectOutputStream(fout);
		oout.writeObject(node);
		System.out.println("writed");
		oout.close();
		fout.close();
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	try {
		FileInputStream fin=new FileInputStream("D:\\test.txt");
		ObjectInputStream oin=new ObjectInputStream(fin);
		DefaultMutableTreeNode inNode;
		inNode=(DefaultMutableTreeNode)oin.readObject();
		System.out.println("readed "+inNode.toString());
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	
	
	
	}
}